package com.leonardo.persistenceme.model.persistancehandlers;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public abstract class PersistenceHandler {

	protected String DB_NAME; 
	protected boolean root = false;
	
	public abstract void persist(Object obj, DataOutputStream stream) 
			throws IOException;
	
	public abstract Object recover(DataInputStream stream) 
			throws IOException;	
	
	public void prePersist(Object obj) { }
	public void postPersist(Object obj) { }
	public void preLoad() { }
	public void postLoad(Object obj) { }
	public void preDelete(Object obj) { }
	public void postDelete(Object obj) { }
	
	public void setAsRoot(String name) {
		DB_NAME = name;
		root = true;
	}
	
	public void setDB_NAME(String name) {
		DB_NAME = name;
	}
}
